<?php
/*
 *	RATE PLUGIN
 *	@package rate
 *	@author Miguel Montes mmontesp@gmail.com
 *	@license GNU General Public License (GPL) version 2
 *	@copyright (c) Miguel Montes 2008
 *	@link http://community.elgg.org/pg/profile/mmontesp
 */
	$opt = array(elgg_echo("rate:0")=>1, elgg_echo("rate:1")=>2, elgg_echo("rate:2")=>3, elgg_echo("rate:3")=>4, elgg_echo("rate:4")=>5, elgg_echo("rate:5")=>6);
	
	$rate = $vars['entity']->getAnnotationsAvg('generic_rate');
	$image = round($rate*2);
	$rate = $image/2;
	$alt = array_keys($opt);
	$alt = $alt[$rate];
	
	echo list_annotations($vars['entity']->getGUID(),'generic_ratecomment',10,false);
	echo "<div id=\"rate\"><img src='{$CONFIG->wwwroot}mod/validation_peda/graphics/$image.gif' alt='$alt' title='$alt'/> (".$vars['entity']->countAnnotations('generic_rate')." ".elgg_echo("rate:rates").")</div>";
	$ratecomment='';

	$form_body = "<hr><div class=\"contentWrapper search_listing\"><p><label>".elgg_echo("rate:text")."</label></p>";
	$form_body .= "<p>" . elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $vars['entity']->getGUID()));
	$form_body .= "<p>" . elgg_view('input/rate', array('internalname' => 'rate', 'options' => $opt));
	$form_body .= "<p>" . elgg_view('input/longtext', array('internalname' => 'ratecomment', 'value' => $ratecomment));
	$form_body .= elgg_view('input/submit', array('value' => elgg_echo("rate:rateit"))) . "</p></div>";
	echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$vars['url']}action/validation_peda/add"));


?>